//------------------------------------------------------------------------------
// Copyright (c) 2008 www.dnaide.com
// Licensed under the MIT (MIT-LICENSE.txt)
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
using System.Security.Cryptography;
using System.IO;

namespace DNAide.Core
{
	/// <summary>
	/// String helper methods e.g. GeneratePassword, Left, Right, Mid, Truncate
	/// </summary>
	public static partial class StringAide
	{
		
		/// <summary>
		/// String writer with encoding. .NET StringWriter is UTF-16 only.
		/// </summary>
		public class StringWriterWithEncoding : StringWriter
		{
			private Encoding _encoding;

			/// <summary>
			/// Encoding
			/// </summary>
			public override Encoding Encoding
			{
				get
				{
					return _encoding;
				}
			}
			/// <summary>
			/// String writer with encoding. .NET StringWriter is UTF-16 only.
			/// </summary>
			/// <param name="encoding"></param>
			public StringWriterWithEncoding(Encoding encoding)
			{
				_encoding = encoding;
			}
		}

		
		/// <summary>
		/// Returns string "true" or "false"
		/// </summary>
		/// <param name="value">Boolean value</param>
		/// <returns>String</returns>
		public static String GetStringFromBool(Boolean value)
		{
			return value ? "true" : "false";
		}


		/// <summary>
		/// Returns string "yes" or "no"
		/// </summary>
		/// <param name="value">Boolean value</param>
		/// <returns>String</returns>
		public static String GetStringYesNoFromBool(Boolean value)
		{
			return value ? "yes" : "no";
		}


		/// <summary>
		/// An invariant culture version of String.Format
		/// </summary>
		/// <param name="format">String format</param>
		/// <param name="args">Args</param>
		/// <returns></returns>
		public static String FormatInvariant(String format, params Object[] args)
		{
			return String.Format(CultureInfo.InvariantCulture, format, args);
		}

	}
}
